let xhr = new XMLHttpRequest();
xhr.open('get','www.baidu.com',false);
xhr.send(null);
xhr.onreadystatechange = function(){
  if(xhr.readyState == 4){
    if(xhr.status >=200 && xhr.status < 300 || xhr.status === 304){
        alert(xhr.responseText)
    } else {
        alert('xhr is unsuccessful'+xhr.status)
    }
  }
}